home *** CD-ROM | disk | FTP | other *** search
- Path: bigboote.WPI.EDU!cs!shura
- From: shura@cs.wpi.edu (Alexander Schelkin)
- Newsgroups: comp.lang.c++
- Subject: HELP: Virtual output stream functions
- Date: 27 Mar 1996 14:52:54 GMT
- Organization: Worcester Polytechnic Institute Computer Science Department
- Distribution: world
- Message-ID: <4jbko6$ivo@bigboote.WPI.EDU>
- NNTP-Posting-Host: owl.wpi.edu
-
- I have a base class (Base) and several derived classes (Derived1,
- Derived2, ...). How can I implement a virtual operator<<?
-
- I would like to be able to do the following:
-
- If I have operator<< for Base, Derived1 and Derived2.
-
- Base* p1 = new Derived1;
- Base* p2 = new Derived2;
- cout << "Derived 1 " << (*p1) << endl;
- cout << "Derived 2 " << (*p2) << endl;
-
- But in this case an output I got comes from Base class operator<<,
- not from the derived classes.
-
- Please answer me to shura@cs.wpi.edu
-
- Thanks a lot,
- Alexander Schelkin
-
-
-